package com.hmyd.hmyd_android.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import com.hmyd.hmyd_android.R;

public class SignInDialog extends Dialog {

	private ImageView mIvAnim;
	private TextView mTvScore;
	private String score;
	private AnimationDrawable animationDrawable;

	public SignInDialog(Context context) {
		super(context);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

	}

	public SignInDialog(Activity context, int theme, String stringTip) {
		super(context, theme);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		score = stringTip;

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_signin);

		mIvAnim = (ImageView) findViewById(R.id.sign_anim);
		mTvScore = (TextView) findViewById(R.id.sign_score);
		mTvScore.setText("+"+score);
		
		mIvAnim.setBackgroundResource(R.anim.ind_qian_animation);
		animationDrawable = (AnimationDrawable)mIvAnim.getBackground();
//		animationDrawable.addFrame(getContext().getResources().getDrawable(R.anim.qian2), 450);
//		animationDrawable.addFrame(getContext().getResources().getDrawable(R.anim.qian3), 450);
	}
	
	@Override
	public void show() {
		if (null != animationDrawable) {
			animationDrawable.start();
		}
		
		super.show();
	}
	
	@Override
	public void dismiss() {
		super.dismiss();
		if (null != animationDrawable && animationDrawable.isRunning()) {
			animationDrawable.stop();
			animationDrawable = null;
		}
	}
}
